Skip to content

AO3-1173 We need a comment preview#5835

Draft
forceofcalm wants to merge 28 commits into
otwcode:masterfrom
forceofcalm:AO3-1173
Draft

AO3-1173 We need a comment preview#5835
forceofcalm wants to merge 28 commits into
otwcode:masterfrom
forceofcalm:AO3-1173

Conversation

@forceofcalm
Copy link
Copy Markdown
Contributor

Pull Request Checklist

Issue

https://otwarchive.atlassian.net/browse/AO3-1173

Purpose

This change adds a JavaScript-free "comment preview" (similar to work previews) for the commenting system. It should display the parsed HTML in a similar template to how the comment would actually be displayed. It preserves the body/info of the comment, as well as the user info between pages, allowing a user to edit the details until it looks right.

I would like some feedback on a few things:

  • The implementation: I'm a bit wary about sending the data in the URL params, but as mentioned in the comments of the Jira ticket, sessionStorage and its ilk are out of the question, and I'm not sure we want to implement any comment draft system on the backend.
  • The template: I think if we want to emulate the current comment appearance in the preview, then it might be best to have a shared template for comments so that any style changes will be consistent in the preview without needing to edit both places. I wasn't sure whether this would be welcome or warranted, and, if so, what best practices would apply to this codebase when creating the template.
  • The style rule for text-align: right. I hate how this rule looks, but I'm not sure if we have any better practices for the naming/style rule conventions I can take advantage of here.

Testing Instructions

I will update the Jira ticket once this code looks close to being ready to merge; until then I want to wait until the flow is solidified and approved.

Credit

calm (they/them)

@forceofcalm forceofcalm marked this pull request as draft May 22, 2026 18:48
@slavalamp
Copy link
Copy Markdown
Contributor

thoughts (as a fellow contributor):

sending the data

is there a reason it couldn't be sent as POST request params, like when you're previewing it?

also i just checked how dreamwidth does it, and it actually has both the comment preview and the edit form on the preview page. that's maybe an even better alternative to jumping between different pages?

shared template

that would make total sense to do, you could call it _comment_content.html.erb

The style rule for text-align: right

i don't see any any div.actions.right elements here so i'm not sure what its purpose is?

@slavalamp
Copy link
Copy Markdown
Contributor

also i just checked how dreamwidth does it

i also just noticed that the dreamwidth comment preview page also has a copy of whatever post or comment you're replying to... not sure if livejournal's previews that sarken mentioned are the same

but i suppose you could also just use javascript by default to fetch the preview and insert it somewhere in or near the comment form, and only fall back to a separate page without it

@forceofcalm
Copy link
Copy Markdown
Contributor Author

@slavalamp Hi! Thanks for the feedback.

I'll definitely look into a preview that includes the comment one is replying to if one exists. I am also willing to workshop the actual design of the preview page.

One thing to note, though, is that the request (and, from what I understand, AO3 in general) asked for JavaScript-based features to be avoided. If it didn't, I would have approached all of this completely differently. So, with that in mind, we are certainly more limited on what can be done.

That being said, I think having the preview and the edit form on the same page makes sense. I was trying to imitate the work preview flow, but I think since comments are generally shorter, having them on the same page is more reasonable. I'll also start working on showing the parent comment alongside the preview comment; that's a great idea, and I think it should be possible to implement.

I also mentioned creating a comment template for this and other features, but I think I decided to do that in a different PR, so this doesn't become too bloated a change. I'll also probably revert my ts() to t() changes outside of what Rubocop suggested for the same reasons; the PR is already pretty big as it is, and I'd like to avoid scope creep so that this can go out sooner.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants